<?php
class Login extends CI_Controller {

	function index()
	{
		// LOAD HELPERS
		$this->load->helper(array('form'));
		// SET VALIDATION RULES
		$this->form_validation->set_rules('agency_tk_user', $this->lang->line('username'), 'required');
		$this->form_validation->set_rules('agency_tk_pass', $this->lang->line('password'), 'required');
		$this->form_validation->set_rules('agency_email', $this->lang->line('email'), 'required');
		$this->form_validation->set_rules('agency_phone', $this->lang->line('phone'), 'required');
		$this->form_validation->set_rules('agency_remark', $this->lang->line('remark'), 'required');
		//$this->form_validation->set_error_delimiters('<em>','</em>');

		// has the form been submitted and with valid form info (not empty values)
		if($this->input->post('login'))
		{
			if($this->form_validation->run())
			{
				$agency_array = array(
						'agency_tk_user'=>$this->input->post('agency_tk_user'),
						'agency_tk_pass'=>$this->input->post('agency_tk_pass'),
						'agency_email'=>$this->input->post('agency_email'),
						'agency_phone'=>$this->input->post('agency_phone'),
						'agency_remark'=>$this->input->post('agency_remark'),
						'logged_in'=>true,
						);
				$this->session->set_userdata($agency_array);
				//print_r($agency_array);
				redirect('searchflight');
			}
		}
		
		$this->template->write('title', $this->lang->line('login'));
		$this->template->write_view('left_side_bar_top', 'login');
		$this->template->write_view('content', 'login_notes');
		$this->template->render();
	}
}

/* End of file main.php */
/* Location: ./application/controllers/main.php */